<?php
/**
 * Created By Project
 * Author: 陈东
 * Copyright：陈东
 * Source Code：陈东
 * Explain：I shall not authorize for any other commercial purposes, law breakers must be prosecuted.
 */
namespace Home\Controller;
use Think\Controller;

class UploadController extends BaseController {
	
	public function index(){
		
		$this->display();
	}
	
	/*
	 * 视频上传
	 */
	public function up(){
		
		$size = 31457280;
		$exts = 'mp4';
		$rootpath = './Uploadmp4/';
		$upload = new \Think\Upload();			//实例化上传类
		$upload->maxSize   =     $size;			//设置附件上传大小30M
		$upload->exts      =     array($exts);	//设置附件上传类型
		$upload->rootPath  =     $rootpath; 	//设置附件上传根目录
		// 上传单个文件
		$info   =   $upload->uploadOne($_FILES['myfiles']);
		if(is_array($info)){
			if($info['ext']!=$exts){
				echo 1;//格式不正确
			}else if($info['size']>$size){
				echo 2;//超出限定范围30M
			}else if(empty($info['name'])){
				echo 3;//没有上传文件
			}else{
				//echo C('WEBDOMAIN').'/'.$info['savepath'].$info['savename']; //返回路径
				echo ltrim($rootpath.$info['savepath'].$info['savename'],'.');
			}
		}else{
			echo 0;//上传失败
		}
	}


}